package o;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.DialogInterface.OnShowListener;
import android.view.View;
import android.widget.Button;
import com.huawei.gamebox.service.welfare.gift.bean.GiftCardBean;
import com.huawei.gamebox.service.welfare.gift.bean.PlayerRoleInfo;
import java.util.List;

public class fcj implements fcm {
    private fch ʼ;
    private AlertDialog ˊ;
    private int ˋ;
    private GiftCardBean ˎ;
    private OnDismissListener ˏ;
    private Context ॱ;

    final class a extends evx {
        final /* synthetic */ fcj ॱ;

        private a(fcj o_fcj) {
            this.ॱ = o_fcj;
        }

        public void ˋ(View view) {
            PlayerRoleInfo ˋ = this.ॱ.ʼ.ˋ();
            if (ˋ != null) {
                new fbx(this.ॱ.ॱ, this.ॱ.ˎ, this.ॱ.ˋ).ˋ(ˋ);
            } else {
                Logger.ˏ("GiftSelectRoleDialog", "playerRoleInfo == null");
            }
            if (this.ॱ.ˊ != null) {
                this.ॱ.ˊ.dismiss();
            }
            if (this.ॱ.ˏ != null) {
                this.ॱ.ˏ.onDismiss(this.ॱ.ˊ);
            }
        }
    }

    static final class d implements OnClickListener {
        private d() {
        }

        public void onClick(DialogInterface dialogInterface, int i) {
            if (dialogInterface != null) {
                dialogInterface.dismiss();
            }
        }
    }

    fcj(Context context, List<PlayerRoleInfo> list, GiftCardBean giftCardBean, int i, OnDismissListener onDismissListener) {
        this.ॱ = context;
        this.ˎ = giftCardBean;
        this.ˋ = i;
        this.ʼ = new fch(context);
        this.ʼ.ˊ(list);
        this.ʼ.setListener(this);
        this.ˏ = onDismissListener;
        ॱ(context);
    }

    fcj(Context context, List<PlayerRoleInfo> list, GiftCardBean giftCardBean, int i) {
        this(context, list, giftCardBean, i, null);
    }

    private void ॱ(Context context) {
        this.ˊ = new Builder(context).setTitle(fcl.ॱ(exp$f.ʿ)).setMessage(null).setPositiveButton(fcl.ˊ(context.getString(exp$f.ॱ)), null).setNegativeButton(exp$f.ॱˎ, new d()).setView(this.ʼ).create();
        this.ˊ.setOnDismissListener(this.ˏ);
        ayw.ˊ(this.ˊ.getWindow());
        this.ˊ.setOnShowListener(new OnShowListener(this) {
            final /* synthetic */ fcj ॱ;

            {
                this.ॱ = r1;
            }

            public void onShow(DialogInterface dialogInterface) {
                if (this.ॱ.ˊ != null) {
                    this.ॱ.ˊ.getButton(-1).setOnClickListener(new View.OnClickListener(this) {
                        final /* synthetic */ AnonymousClass1 ˎ;

                        {
                            this.ˎ = r1;
                        }

                        public void onClick(View view) {
                            this.ˎ.ॱ.ʼ.ॱ();
                        }
                    });
                }
            }
        });
    }

    public void ˎ() {
        if (!(this.ॱ instanceof Activity) || ((Activity) this.ॱ).isFinishing()) {
            Logger.e("GiftSelectRoleDialog", "invalid context");
            return;
        }
        try {
            this.ˊ.show();
        } catch (Exception e) {
            Logger.e("GiftSelectRoleDialog", "show select dialog error");
        }
    }

    public void ˋ() {
        if (this.ˊ == null) {
            Logger.e("GiftSelectRoleDialog", "toLastPage dialog == null");
            return;
        }
        Button button = this.ˊ.getButton(-1);
        button.setText(fcl.ˊ(this.ॱ.getString(exp$f.ˈ)));
        button.setOnClickListener(new a());
    }
}
